﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TreaShares.Backoffice.Controlers;
using TreaShares.Backoffice.DataLayer;

namespace TreaShares.Backoffice.User
{
    public partial class Reports : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            ReportsManager rm = new ReportsManager();
            Report report= rm.SelectReport(int.Parse(Request.QueryString["ReportId"].ToString()));
            this.Title += string.Format (" - {0}", report.DisplayName);
            string typeName = string.Format("TreaShares.Reports.{0}, TreaShares.Reports", report.ReportClassName);
            Type type = Type.GetType(typeName);
            try
            {
                var rprt = Activator.CreateInstance(type) as Telerik.Reporting.Report;
                rprt.ReportParameters["ClientId"].Value = this.Master.OrgBasicInfo.Id.ToString();
                
                //rprt.ReportParameters["ValueDate"].Value = DateTime.Now;
                //rprt.ReportParameters["Stock"].Value = "PEPSI COMMON";
                this.ReportViewer1.Report = rprt;
            }
            catch (Exception ex)
            {
                lblMsg.Text = ex.Message;             
            }
        }
      
    }
}